package logic

import (
	"B/renrenzhuB_srv/model/mysql"
	"context"

	"B/renrenzhuB_srv/internal/svc"
	"B/renrenzhuB_srv/renrenzhuB"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewOrderListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderListLogic {
	return &OrderListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *OrderListLogic) OrderList(in *renrenzhuB.OrderListRequest) (*renrenzhuB.OrderListResponse, error) {
	// todo: add your logic here and delete this line
	var g mysql.Order
	list := g.List()
	var order []*renrenzhuB.OrderList
	for _, o := range list {
		order = append(order, &renrenzhuB.OrderList{
			UserId:  int64(o.UserId),
			OrderId: o.OrderId,
			Amount:  float32(o.Amount),
			Payment: o.Payment,
			Status:  o.Status,
		})
	}
	return &renrenzhuB.OrderListResponse{List: order}, nil
}
